<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
	<xsl:template match="field[@type = 'image_pack' and parent::doctype]">
		<xsl:variable name="is_new" select="parent::doctype/@action = 'create'"/>
		<xsl:variable name="document_field" select="../../document[@doctype_name = current()/parent::doctype/@name]/field[@name = current()/@name]"/>
		<div class="field">
			<label class="title_label" for="{@name}">
				<xsl:value-of select="@title"/>
				<xsl:text>:&#160;</xsl:text>
			</label>
			<xsl:if test="$document_field/image/@is_uploaded = 1">
				<div class="images-">
					<xsl:if test="not($document_field/image[@is_uploaded = 1 and @width &lt;= 260 and @height &lt;= 260])">
						<a href="{$document_field/image[1]/@url}?{$document_field/@rand}">
							<xsl:apply-templates mode="dtf_image_pack_see" select="." />
						</a>
					</xsl:if>
					<xsl:for-each select="$document_field/image[@is_uploaded = 1 and @width &lt;= 260 and @height &lt;= 260]">
						<xsl:choose>
							<xsl:when test="$document_field/image[@is_uploaded = 1 and @width &gt; 260 or @height &gt; 260]">
								<a href="{$document_field/image[@is_uploaded = 1 and @width &gt; 260 or @height &gt; 260]/@url}">
									<img src="{@url}?{../@rand}" alt="{@name}" width="{@width}" height="{@height}" style="margin-right: 5px"/>
								</a>
							</xsl:when>
							<xsl:otherwise>
								<img src="{@url}?{../@rand}" alt="{@name}" width="{@width}" height="{@height}" style="margin-right: 5px"/>
							</xsl:otherwise>
						</xsl:choose>
					</xsl:for-each>
				</div>
			</xsl:if>
			<input id="{@name}" class="file-" type="file" name="{@name}" value="{$document_field}">
			</input>
			<xsl:if test="$document_field/image/@is_uploaded = 1">
				<div class="inline_labels">
					<input id="{@name}_delete" class="checkbox-" type="checkbox" name="{@name}_delete">
						<xsl:choose>
							<xsl:when test="../../pass_info/vars/var[@name = concat(current()/@name, '_delete')]">
								<xsl:attribute name="checked">checked</xsl:attribute>
							</xsl:when>
						</xsl:choose>
					</input>
					<label for="{@name}_delete">
						<xsl:apply-templates mode="dtf_image_pack_delete_image" select="." />
					</label>
				</div>
			</xsl:if>
			<xsl:apply-templates mode="dtf_error" select="." />
			<xsl:if test="@comment != ''">
				<div class="comment-">
					<xsl:value-of select="@comment"/>
				</div>
			</xsl:if>
		</div>
	</xsl:template>
</xsl:stylesheet>
